#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>  
#include <pthread.h>
using namespace std;
void* recv_back(void*arg)
{
   char msg[128]={0};
   int fd=  *(int*)arg;

   while(1)
   { 
     memset(msg,0,128);
     if(recv(fd,msg,128,0)<0)
     {cout<<"recv fail..."<<endl;}


     printf("%s\r\n",msg);
     //




   }







}
int main()
{
  

  int sockfd=socket(AF_INET,SOCK_STREAM,0);
  if(sockfd<0)
  {
     cout<<" sockfd fail!!!"<<endl;
  }
    //cout<<"sockfd 成功"<<endl;

  struct sockaddr_in server;
  socklen_t len=sizeof(server);
  server.sin_family=AF_INET;
  server.sin_port=htons(1884);
  server.sin_addr.s_addr=inet_addr("172.28.76.233");
  

   if(connect(sockfd,(const sockaddr*)&server,len)<0)
   {cout<<"connect fail..."<<endl;
     return 0;}
     cout<<"connect 成功"<<endl;
   char msg[1024]={0};
   msg[0]=0x60;
                     
   const char* buffer="{\"username\":\"0007\",\"password\":\"111\"}";

   memcpy(msg+1,buffer,strlen(buffer));
   
   send(sockfd,msg,strlen(buffer)+1,0);
   
   pthread_t tid;
   pthread_create(&tid,NULL,recv_back,&sockfd);

   while(1);
   return 0;

}